<template>
  <Echart :options="options" id="centreLeft1Chart" height="500px" width="600px"></Echart>
</template>

<script>
import Echart from "@/common/echart";

const animationDuration = 6000;

export default {
  props: {
    cdata: {
      type: Object,
      default: () => ({})
    }
  },
  components: {
    Echart
  },
  data() {
    return {
       options: {},
    };
  },
  watch: {
    cdata: {
      handler(newData) {
        this.options = {
            color: [
            "#37a2da",
            "#32c5e9",
            "#9fe6b8",
            "#ffdb5c",
            "#ff9f7f",
            "#fb7293",
            "#e7bcf3",
            "#8378ea"
          ],
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b} : {c} ({d}%)",
            textStyle:{ 
              fontSize:22
            }
          },
          legend: {
            left: "center",
            bottom: "10",
            data: newData.xData,
            textStyle:{ 
              fontSize:22
            }
          },
          series: [
            {
              name: newData.seriesName,
              type: "pie",
              roseType: "radius",
              radius: [15, 95],
              center: ["50%", "38%"],
              data: newData.seriesData,
              animationEasing: "cubicInOut",
              animationDuration: 2600,
              label:{ 
                fontSize:22
              }
            }
          ]
        };
      },
      immediate: true,
      deep: true
    }
  }
};
</script>
